package com.mqy.springmvc.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 13159 //作者
 * @version V1.0 //版本
 * @Project 2022.3.8MVCxiaojie
 * @Package com.mqy.springmvc.interceptor
 * @Description:
 * @Date 2022/3/8 20:10//日期
 * @Motto:放下杂念,只为迎接明天更好的自己
 */
/*拦截器*/
@Component
public class MyLoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        /*到达之前执行*/
        System.out.println("MyLoginInterceptor中的方法preHandle执行了");
        return true;
        //return false;//不放行
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
     /*到达回来之后完成*/
        System.out.println("MyLoginInterceptor中的方法postHandle执行了");
       }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
       /*请求完成之后*/
        System.out.println("MyLoginInterceptor中的方法afterCompletion执行了");
           }
}
